<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>setInterval() 方法</title>
</head>

<body>
    <p>单击按钮每3秒出现一个“Hello”警告框。</p>
    <p>再次点击警告框，经过3秒出现新的警告框，这将一直执行 ...</p>
    <button onclick="myFunction()">点我</button>
    <script>
        function myFunction() {
            setInterval(function () { alert("Hello") }, 3000);
        }
    </script>
</body>

</html>